<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	version="2.0">

	<xsl:output method="text" />
	<xsl:output method="text" name="php" />

	<xsl:template match="//class">
	
		<xsl:variable name="filename" select="concat(@name,'.php')" />
		<xsl:value-of select="$filename" />

		<xsl:result-document href="{$filename}" format="php">
public class <xsl:value-of select="@name" />
{
			<xsl:for-each select="./properties/*">
				<xsl:choose>
					<xsl:when test="@collectionItem = 'true'">
  /**
  * @var array[<xsl:value-of select="@type"/>]
  */  
  private $<xsl:value-of select="@name"/>s = array();
  					
					</xsl:when>
					<xsl:otherwise>
  /**
  * @var <xsl:value-of select="@type"/>
  */  
  private $<xsl:value-of select="@name"/>;
  					
					</xsl:otherwise>
				</xsl:choose>
			</xsl:for-each>
			
						<xsl:for-each select="./properties/*">
				<xsl:choose>
					<xsl:when test="@collectionItem = 'true'">
  /**
  * @return array[<xsl:value-of select="@type"/>]
  */  
  public function get<xsl:value-of select="@name"/>s()
  {
    return $this-><xsl:value-of select="@name"/>s;
  }
  
  /**
  * @param <xsl:value-of select="@type"/> 
  */  
  public function add<xsl:value-of select="@name"/>( <xsl:value-of select="@type"/> $<xsl:value-of select="@name"/> )
  {
    $this-><xsl:value-of select="@name"/>s[] = $<xsl:value-of select="@name"/>;
  }
  					
					</xsl:when>
					<xsl:otherwise>
  /**
  * @return <xsl:value-of select="@type"/>
  */  
  public function get<xsl:value-of select="@name"/>()
  {
    return $this-><xsl:value-of select="@name"/>;
  }
  
  /**
  * @param <xsl:value-of select="@type"/> 
  */  
  public function set<xsl:value-of select="@name"/>( <xsl:value-of select="@type"/> $<xsl:value-of select="@name"/> )
  {
    $this-><xsl:value-of select="@name"/> = $<xsl:value-of select="@name"/>;
  }
  					
					</xsl:otherwise>
				</xsl:choose>
			</xsl:for-each>
			

}
		</xsl:result-document>
		<xsl:apply-templates/>
		
	</xsl:template>	
<!-- 
	
	<xsl:template match="//property">
	
	<xsl:variable name="prop-type-camel">
		<xsl:value-of select="concat( upper-case(substring( @type,1,1) , substring(@type,2)"/>
	</xsl:variable>
	
	<xsl:variable name="prop-name-camel">
		<xsl:value-of select="concat( lower-case(substring( @name,1,1) , substring(@name,2)"/>
	</xsl:variable>
	
	<xsl:variable name="prop-name-function">
		<xsl:value-of select="concat( upper-case(substring( @name,1,1) , substring(@name,2)"/>
	</xsl:variable>
	
				<xsl:choose>
					<xsl:when test="@collectionItem = 'true'">
  /**
  * @return array[<xsl:value-of select="@type"/>]
  */  
  public function get<xsl:value-of select="@name"/>s()
  {
    return $this-><xsl:value-of select="@name"/>s;
  }
  
  /**
  * @param <xsl:value-of select="@type"/> 
  */  
  public function add<xsl:value-of select="@name"/>( <xsl:value-of select="@type"/> $<xsl:value-of select="@name"/> )
  {
    $this-><xsl:value-of select="@name"/>s[] = $<xsl:value-of select="@name"/>;
  }
  					
					</xsl:when>
					<xsl:otherwise>
  /**
  * @return <xsl:value-of select="@type"/>
  */  
  public function get<xsl:value-of select="@name"/>()
  {
    return $this-><xsl:value-of select="@name"/>;
  }
  
  /**
  * @param <xsl:value-of select="@type"/> 
  */  
  public function set<xsl:value-of select="@name"/>( <xsl:value-of select="@type"/> $<xsl:value-of select="@name"/> )
  {
    $this-><xsl:value-of select="@name"/> = $<xsl:value-of select="@name"/>;
  }
  					
					</xsl:otherwise>
				</xsl:choose>
	</xsl:template>

 -->
</xsl:stylesheet>

